package com.zhiwang.planet.widget.highlight.shape

import android.graphics.*
import com.zhiwang.planet.widget.highlight.HighLight

object CircleDashShape : HighLight.LightShape {

    override fun overlayShape(bitmap: Bitmap, viewPosInfo: HighLight.ViewPosInfo): Boolean {
        val canvas = Canvas(bitmap)
        val paint = Paint(Paint.ANTI_ALIAS_FLAG)
        paint.style = Paint.Style.STROKE
        paint.strokeWidth = 4f
        paint.color = Color.WHITE
        paint.isDither = true
        paint.isAntiAlias = true
        paint.pathEffect = DashPathEffect(floatArrayOf(10f, 10f), 1f)
        val rectF = viewPosInfo.rectF
        canvas.drawCircle(rectF.left + rectF.width() / 2, rectF.top + rectF.height() / 2,
                Math.max(rectF.width(), rectF.height()) / 2, paint)
        return true
    }

    override fun shape(bitmap: Bitmap, viewPosInfo: HighLight.ViewPosInfo) {

        val canvas = Canvas(bitmap)
        val paint = Paint(Paint.ANTI_ALIAS_FLAG)

        val rectF = viewPosInfo.rectF
        val offset = 10
        rectF.set(rectF.left - offset, rectF.top - offset, rectF.right + offset, rectF.bottom + offset)
        paint.style = Paint.Style.FILL
        canvas.drawCircle(rectF.left + rectF.width() / 2, rectF.top + rectF.height() / 2,
                Math.max(rectF.width(), rectF.height()) / 2, paint)

    }
}